﻿using Business.Common.tbNavigation;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Metadata;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;

namespace Business.EntityFrameworkCore
{
    [ConnectionStringName("FileStorage")]
    public class BusinessDbContext : AbpDbContext<BusinessDbContext>
    {
       
        public BusinessDbContext(DbContextOptions<BusinessDbContext> options) : base(options)
        {

        }
        public virtual DbSet<TbNavigation> TbNavigation { get; set; } //这里是添加表用来迁移

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ConfigureFileStorage(); //写完这里回报错 不用管接着写下面的一步就可以了
        }
    }

    public class BloggingContextFactory : IDesignTimeDbContextFactory<BusinessDbContext>
    {
        public BusinessDbContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder<BusinessDbContext>();
            optionsBuilder.UseSqlServer($"Server=localhost;Database=ABP;Trusted_Connection=True;");

            return new BusinessDbContext(optionsBuilder.Options);
        }
    }


}
